﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;

namespace ASCIIRipper
{
    class Program
    {
        static void Main(string[] args)
        {
            Bitmap source = new Bitmap("romfont8x8.png", false);
            Bitmap destination = new Bitmap(16, 16, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Color[] colors = new Color[] {
                Color.Black,
                Color.Navy,
                Color.Green,
                Color.Teal,
                Color.Maroon,
                Color.Purple,
                Color.Olive,
                Color.Silver,
                Color.Gray,
                Color.Blue,
                Color.Lime,
                Color.Aqua,
                Color.Red,
                Color.Fuchsia,
                Color.Yellow,
                Color.White
            };
            int colorIndex = 0;
            foreach (Color color in colors)
            {
                for (int column = 0; column < 16; ++column)
                {
                    for (int row = 0; row < 16; ++row)
                    {
                        for (int x = 0; x < 16; ++x)
                        {
                            for (int y = 0; y < 16; ++y)
                            {
                                Color sourceColor = source.GetPixel(column * 16 + x, row * 16 + y);
                                Color destinationColor = Color.FromArgb(sourceColor.A, color.R, color.G, color.B);
                                destination.SetPixel(x, y, destinationColor);
                            }
                        }
                        string fileName = string.Format("{0}_{1}.png",colorIndex,column+row*16);
                        destination.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
                        Console.WriteLine(fileName);
                    }
                }
                colorIndex++;
            }
            Console.ReadLine();
        }
    }
}
